<?php

namespace app\admin\controller\buddha;

use app\common\controller\AdminController;
use app\common\lib\Show;
use app\common\lib\Status;
use EasyAdmin\annotation\ControllerAnnotation;
use EasyAdmin\annotation\NodeAnotation;
use think\App;

/**
 * @ControllerAnnotation(title="buddha_article")
 */
class Article extends AdminController
{

    use \app\admin\traits\Curd;

    public function __construct(App $app)
    {
        parent::__construct($app);

        $this->model = new \app\common\model\BuddhaArticle();
        
        $this->assign('getStatusList', $this->model->getStatusList());

    }

    public function getArticleByIdList(){
        $title = $this->request->param('val','','trim');
        if(empty($title)){
            return Show::json_show(Status::status_error,"内部错误");
        }
        try {
            $lists = $this->model
                ->field('id as value,title as name')
                ->where('title', 'like', "%{$title}%")
                ->select()
                ->toArray();
        }catch (\Exception $e){
            return Show::json_show(Status::status_error,"内部错误");
        }
        return Show::json_show(Status::status_normal,"ok",$lists);
    }
}